// 引入get post等装饰器
import { Controller,Inject, Get,Post,Request,Query,Param,Headers } from '@nestjs/common';
import { GirlService } from './girl.service';
import { BoyService } from 'src/boy/boy.service';
// import { GlobalModule } from 'src/config/config.module';
// 先建立一个模块，在建立一个模块的controller
// nest g module girl ---no-spec建立一个模块
// nest g controller girl --no-spec建立一个模块对应的路由
// nest g service girl --no-spec建立一个编写业务逻辑的service层文件
@Controller('girl')
// 要使用的其他的模块都需要先在这里注入
export class GirlController {
    // 相当于this.girlService=new GirlService(),
    constructor(
        @Inject("girl") private girlService:GirlService,
        @Inject("girlArray") private girls:object[],
        @Inject("factory") private factory:string,
        @Inject("GlobalModule") private GlobalModule:string,
        // @Inject("boy") private boyService:BoyService
        // 注入的简写形式
        private BoyService:BoyService
        ){}

    @Get('add')
    addGirl():any{
        return this.girlService.addGirl();
    }
    @Get('delete/:id')
    delGirl(@Param() parmas):any{
        let id=parseInt(parmas.id);
        return this.girlService.delGirl(id);
    }
    @Get('update/:id')
    updateGirl(@Param() parmas):any{
        let id=parseInt(parmas.id);
        return this.girlService.updateGirl(id);
    }
    @Get('findAll')
    findAll():any{
        return this.girlService.getGirls()
    }
    @Get('findOne/:name')
    getGirlByName(@Param() parmas):any{
        return this.girlService.getGirlByName(parmas.name);
    }
    @Get('test')
    test():any{
        // return this.factory;
        // return this.BoyService.findAll()
        return this.GlobalModule;
    }
    @Get('cors')
    cors():object{
        return {
            code:200,
            msg:"cors success"}
    }
}
